#define _CRT_SECURE_NO_WARNINGS
#include<vector>
using namespace std;
int maxProfit(vector<int>& prices) {
    int maxprofit = 0;
    int minprice = INT_MAX;
    for (auto& price : prices) {
        maxprofit = max(maxprofit, price - minprice);
        minprice = min(minprice, price);
    }
    return maxprofit;
}
int main() {
    vector<int> v = { 7,1,5,3,6,4 };
    maxProfit(v);
    return 0;
}